home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
PROGRAM
/
MAKECH.ARJ
/
MAKECH.DOC
next >
Wrap
Text File
|
1992-04-23
|
3KB
|
91 lines
MakeCh - Clipper5 supporting utility
======================================
Placed in public domain by the author: John Lucas
Toronto, CANADA
CIS 73700,1074
I hope other developers find this program useful. However John Lucas
takes no responsibility for anything at all. You get what you paid for.
=========================================================================
For Clipper 5.0 developers the program builds and maintains an
application specific header file containing definitions of each
field. This header file is used with the Scatter and Gather user
functions distributed with this program.
To run the program simply type MakeCh at a DOS prompt.
The program will request the drive and path of your project
directory and the path and name of an application specific header file
The following example shows how the header file works in conjunction
with the Scatter and Gather user functions:
Assume a Customer file has been created with three fields:-
CustNum Numeric 3
CustName Character 20
CustAct Logical 1
MakeCh will create a header file (Cust.CH in this example) containing
#Define mCustNum aCustomer[1]
#Define mCustName aCustomer[2]
#Define mCustAct aCustomer[3]
The header file will also contain the definitions for the Scatter and
Gather commands.
Note: If you have an existing application header file MakeCh will add
these definitions to its end. Subsequent runs of MakeCh will leave
your original header code intact only replacing the MakeCh defintions.
Code logic to update a record in the customer file will contain:
#Include "Inkey.ch"
#Include "Cust.ch"
Local aCustomer // Array to hold fields
Use Customer
Scatter to aCustomer // Fill array from current record
@ 10,10 say "Customer number" get mCustNum Picture pCustNum
@ 12,10 say " Name" get mCustName Picture pCustName
@ 14,10 say "Customer active" get mCustActive Picture pCustAct
^
|
------ Get into array
read
if !lastkey() = K_Esc
Gather from aCustomer // Replace from array elements
endif
To add a new customer record use
Scatter to aCustomer New
This will fill the array with the approriate empty values. In this
example 0, space(20) and .F.
NOTE: the local definition of aCustomer. This must be an "a" followed by
the data base name to match the #defines for the fields.
To use scatter and gather from another work area code:
Scatter to aCustomer from Customer
Gather from aCustomer to Customer
WARNING Duplicate field name will give error messages at compile time.
e.g. if CustNum is in both Customer.dbf and Invoice.dbf
mCustNum will be defined as aCustomer[1] and as aInvoice[x]
A CHALLENGE Any bright minds come up with a better way to handle this?
=========== Also I don't really like having to code the Local aALIAS